#include "protect.h"
int main(int argc, char const *argv[])
{
//创建头节点并保存头节点地址
    node_t *phead = NULL;
    creat_node(&phead,-1);
    printf("phead = %p\n",phead);//地址非空

//测试头插函数
    insert_list_by_head(phead,50);
    insert_list_by_head(phead,40);
    insert_list_by_head(phead,30);
    insert_list_by_head(phead,20);
    insert_list_by_head(phead,10);
    printf_list(phead);//10 20 30 40 50 

//测试尾插函数
    insert_list_by_tail(phead,100);
    insert_list_by_tail(phead,200);
    insert_list_by_tail(phead,300);
    printf_list(phead);//10 20 30 40 50 100 200 300

//测试任意插入函数
    insert_list_by_pos(phead,9,400);//报错
    insert_list_by_pos(phead,1,20);
    insert_list_by_pos(phead,4,20);
    printf_list(phead);//10 20 20 30 20 40 50 100 200 300

//测试头删函数
    delete_list_by_head(phead);
    delete_list_by_head(phead);
    printf_list(phead);//20 30 20 40 50 100 200 300

//测试尾删函数
    delete_list_by_tail(phead);
    delete_list_by_tail(phead);
    delete_list_by_tail(phead);
    printf_list(phead);//20 30 20 40 50 

//任意位置删除
    delete_list_by_pos(phead,1);
    delete_list_by_pos(phead,3);
    printf_list(phead);//20 20 40

//修改
    modify_list_by_pos(phead,2,66);
    printf_list(phead);//20 20 66

//查找
    int num = 0;
    int ret = 0;
    ret = search_list_by_pos(phead, 1, &num);
    printf("ret = %d  num = %d\n", ret, num); 

//剔重
    insert_list_by_tail(phead,30);
    insert_list_by_tail(phead,50);
    insert_list_by_tail(phead,20);
    tichong_list(phead);
    printf_list(phead);//20 66 30 50

    













    return 0;
}
